

// export interface IPetData {
//     // level: number;
//     // exp: number;
//     // expToNextLevel: number

import { EPet, EPetSkill, ESkill, EWuxing } from "./Config/Enum";
import { PetConfig } from "./Config/PetConfig";


// }

// export class Pet implements IPet {
//     id: number;
//     name: string;
//     level: number;
//     exp: number;
//     expToNextLevel: number;
//     assigned: boolean; // 是否被分配

//     constructor(id: number, name: string, level: number, exp: number, expToNextLevel: number, assigned: boolean) {
//         this.id = id;
//         this.name = name;
//         this.level = level;
//         this.exp = exp;
//         this.expToNextLevel = expToNextLevel;
//         this.assigned = assigned;
//     }


// }
// export interface IPet{
//     id: number;
//     name: string;
//     level: number;
//     exp: number;
//     expToNextLevel: number;
//     assigned: boolean; // 是否被分配
//     entityType: EPet; // 添加实体类型字段

// }





// export class Pet implements IPet {
//     id: number;
//     name: string;
//     level: number;
//     exp: number;
//     expToNextLevel: number;
//     assigned: boolean; // 是否被分配
//     entityType: EPet; // 添加实体类型字段

//     constructor(id: number, name: string, level: number, exp: number, expToNextLevel: number, assigned: boolean,entityType: EPet = EPet.Pig) {
//         this.id = id;
//         this.name = name;
//         this.level = level;
//         this.exp = exp;
//         this.expToNextLevel = expToNextLevel;
//         this.assigned = assigned;
//         this.entityType = entityType;
//     }
// }
export class PetData {
    id: number;
    name: string;
    desc: string;
    //entityType: EPet;
    level: number = 1;
    exp: number = 0;
    expToNextLevel: number = 100;
    assigned: boolean = false;
    skill: EPetSkill
    wuxing:EWuxing
    strength:number
    agility:number
    intelligence:number
    skillDesc:string
    
    constructor(petType: EPet) {

                //this.playerType = playerType;
                //this.config = PetConfig[petType];
                //this.equipmentStats = {};
        
                const config = PetConfig[petType];
                if (config) {
                    this.id = config.id;
                    this.name = config.name;
                    this.desc = config.desc;
                    //this.entityType = petType;
                    this.level = 1
                    this.exp = 0;
                    this.expToNextLevel = 100;
                    this.assigned = false;
                    this.skill = config.skill;
                    this.wuxing = config.wuxing;
                    this.strength = config.strength;
                    this.agility = config.agility;
                    this.intelligence = config.intelligence;
                    this.skillDesc = config.skillDesc;


                }


        //this.entityType = petType;
    }
    
    // 保存/加载数据
    getPackage() {
        return {
            id: this.id,
            name: this.name,
            desc: this.desc,
            //entityType: this.entityType,
            level: this.level,
            exp: this.exp,
            expToNextLevel: this.expToNextLevel,
            assigned: this.assigned,
            skill: this.skill,
            wuxing: this.wuxing,
            strength: this.strength,
            agility: this.agility,
            intelligence: this.intelligence,
            skillDesc: this.skillDesc

        };
    }
    
    setPackage(data: any) {
        if (data) {
            this.id = data.id || 1;
            this.name = data.name || "default";
            this.desc = data.desc || "default";
            //this.entityType = data.entityType || EPet.Pig;

            this.level = data.level || 1;
            this.exp = data.exp || 0;
            this.expToNextLevel = data.expToNextLevel || 100;
            this.assigned = data.assigned || false;
            this.skill = data.skill
            this.wuxing = data.wuxing
            this.strength = data.strength
            this.agility = data.agility
            this.intelligence = data.intelligence
            this.skillDesc = data.skillDesc
        }
    }
}